package com.mmt.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mmt.po.Message;
import com.mmt.po.User;
import com.mmt.service.ConversationService;

@RestController
@RequestMapping("/ConversationController")
public class ConversationController {
	@Autowired
	private ConversationService conversationService;
	
	@GetMapping("/listContactByUserId")
	public List<User> listContactByUserId(Integer userId) throws Exception{
		return conversationService.listContactByUserId(userId);
	}
	
	@RequestMapping("/listMessageByConversationId")
	public List<Message> listMessageByConversationId(Integer conversation_id) throws Exception{
		return conversationService.listMessageByConversationId(conversation_id);
	}
	
	@RequestMapping("/saveMessage")
	public Integer saveMessage(Message message) throws Exception{
		return conversationService.saveMessage(message);
	}
	
}
